package io.renren.modules.substation.service.impl;

import io.renren.modules.substation.entity.TBusiDevMonitorInfoEntity;
import io.renren.modules.substation.entity.TInfoAreaInfoEntity;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.substation.dao.TInfoVariableInfoDao;
import io.renren.modules.substation.entity.TInfoVariableInfoEntity;
import io.renren.modules.substation.service.TInfoVariableInfoService;


@Service("tInfoVariableInfoService")
public class TInfoVariableInfoServiceImpl extends ServiceImpl<TInfoVariableInfoDao, TInfoVariableInfoEntity> implements TInfoVariableInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String variableType = (String)params.get("variableType");

        IPage<TInfoVariableInfoEntity> page = this.page(
                new Query<TInfoVariableInfoEntity>().getPage(params),
                new QueryWrapper<TInfoVariableInfoEntity>()
                        .eq(variableType!=null&&!variableType.isEmpty(),"VARIABLE_TYPE",variableType)
        );

        return new PageUtils(page);
    }

    public List<TInfoVariableInfoEntity> queryVariableByCondition(TInfoVariableInfoEntity tInfoVariableInfoEntity)
    {
        return (List<TInfoVariableInfoEntity>) baseMapper.queryVariableByCondition(tInfoVariableInfoEntity);
    }

    public List<TInfoVariableInfoEntity> queryVariableKind()
    {
        return (List<TInfoVariableInfoEntity>) baseMapper.queryVariableKind();
    }

    @Override
    public List<TInfoVariableInfoEntity> getVariableList() {
        return baseMapper.getVariableList();
    }

    @Override
    public Map<String, String> getVariableNameMap() {
        Map<String, String> map = new HashMap<>();
        List<TInfoVariableInfoEntity> list = baseMapper.selectList(new QueryWrapper<>());
        for (TInfoVariableInfoEntity obj : list){
            map.put(obj.getVariableId() + obj.getVariableKind(), obj.getVariableName());
        }
        return map;
    }

}